package org.dizena.common.except;

import org.dizena.common.base.enums.EnumResultCode;

/**
 * 自定义业务运行时异常
 */
public class BusinessException extends RuntimeException {
    /**
     * 状态码
     */
    protected int code = 500;
    /**
     * 数据对象
     */
    protected Object data = null;

    public BusinessException() {
        super();
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(EnumResultCode enumResultCode) {
        super(enumResultCode.msg());
        this.code = enumResultCode.code();
    }

    public BusinessException(String message, Object data) {
        super(message);
        this.data = data;
    }

    public BusinessException(int code, String message, Object data) {
        super(message);
        this.code = code;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
